package jkoa.core;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONObject;

public class Context {
	public Request request;
	public Response response;
	public JSONObject state = new JSONObject();

    public Context(Request request, Response response) {
        this.request = request;
        this.response = response;
    }

    public String method() {
        return request.getMethod();
    }

    public String path() {
        return request.getPath();
    }

    public Request getRequest() {
		return request;
	}

	public void setRequest(Request request) {
		this.request = request;
	}

	public Response getResponse() {
		return response;
	}

	public void setResponse(Response response) {
		this.response = response;
	}

	public void setState(JSONObject state) {
		this.state = state;
	}

	public Context status(int statusCode) {
        response.setStatusCode(statusCode);
        return this;
    }

    public Context setHeader(String key, String value) {
        return this;
    }

    public Context send(Object data) {
        response.send(data);
        return this;
    }

    public JSONObject getState() {
        return state;
    }

    public void setState(String key, Object value) {
        state.put(key, value);
    }
}